"""
Case Type   : datakit安装
Case Name   : 下载日志查看内容
Create At   : 2025/4/21
Owner       : @lonely-dance
Description :
    1.下载日志查看内容
    2.清理环境
Expect      :
    1.成功
    2.成功
History     :
"""

import os
import re
import unittest

from yat.test import Node
from yat.test import macro
from testcase.utils.Logger import Logger
from testcase.utils.CommonSH import CommonSH
from testcase.utils.datakit_api.CommonApi import CommonApi


class Tools(unittest.TestCase):
    def setUp(self):
        self.log = Logger()
        self.log.info(f"-----{os.path.basename(__file__)} start-----")
        self.com_sh = CommonSH()
        self.datakit_node = Node('Datakit_Root')
        self.token = self.com_sh.get_token_value(macro.DATAKIT_PASSWD)
        self.log.info(self.token)
        self.assertNotEqual("error", self.token)
        self.com_api = CommonApi(self.token)

    def test_base_ops(self):
        text = '----step1:下载日志查看内容 expect:成功----'
        self.log.info(text)
        file_name = 'visualtool-main.out'
        response = self.com_api.get_system_log_download(file_name)
        self.log.info(response.text)
        self.assertIn("Application Version: ${system.version}", response.text, '执行失败')

    def tearDown(self):
        self.log.info('----无需清理环境----')
        self.log.info(f"-----{os.path.basename(__file__)} finsh-----")
